package com.qianwang.shopmsg.repository.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.qianwang.shopmsg.entity.StudentInfo;
import com.qianwang.shopmsg.entity.StudentSign;
import com.qianwang.shopmsg.entity.view.StudentSignView;
import com.qianwang.shopmsg.repository.BaseDao;
import com.qianwang.shopmsg.repository.StudentMsgDao;

@Repository("studentMsgDao")
@SuppressWarnings("unchecked")
public class StudentMsgDaoImpl extends BaseDao implements StudentMsgDao {

	@Override
	public StudentSign loadStudentSignById(long id) {
		return (StudentSign) getSqlMapClientTemplate().queryForObject("StudentSign.loadStudentSignById", id);
	}
	
	@Override
	public StudentInfo loadStudentInfo(long id) {
		return (StudentInfo)getSqlMapClientTemplate().queryForObject("StudentInfo.loadStudentInfo", id);
	}
	public long addStudentInfo(StudentInfo studentInfo){
		return (Long)getSqlMapClientTemplate().insert("StudentInfo.addStudentInfo", studentInfo);
	}
	
	@Override
	public void addStudentSign(StudentSign studentSign) {
		getSqlMapClientTemplate().insert("StudentSign.addStudentSign", studentSign);
	}
	
	@Override
	public void updateStudentSign(StudentSign studentSign) {
		getSqlMapClientTemplate().update("StudentSign.updateStudentSign", studentSign);
	}
	
	@Override
	public List<StudentSign> listStudentSignInfos(Map<String,Object> param) {
		return (List<StudentSign>)getSqlMapClientTemplate().queryForList("StudentSign.listStudentSignInfos", param);
	}
	
	@Override
	public int countStudentSingInfos(Map<String,Object> param) {
		Integer count = (Integer)getSqlMapClientTemplate().queryForObject("StudentSign.countStudentSingInfos",param);
		return count == null?0:count;
	}
	
	@Override
	public StudentSignView loadSignWithStuInfoById(Map<String, Object> param) {
		return (StudentSignView) getSqlMapClientTemplate().queryForObject("StudentSign.loadSignWithStuInfoById", param);
	}
	
	@Override
	public void updateStudentInfo(StudentInfo studentInfo) {
		getSqlMapClientTemplate().update("StudentInfo.updateStudentInfo", studentInfo);
	}
}
